<?php
/**
 * Created by PhpStorm.
 * User: DD
 * Date: 2016/4/20
 * Time: 15:35
 */

namespace app\admin\services;

use app\common\services\BaseService;
class RoleMenuService extends BaseService
{
    public function savePower($roleId, $menuIds)
    {
        $RoleMenu = $this->getModelInstance();
        $RoleMenu->startTrans();
        $RoleMenu->where(array('role_id' => $roleId))->delete();
        foreach (explode(',', $menuIds) as $id) {
            $RoleMenu->add(array(
                'role_id' => $roleId,
                'menu_id' => $id
            ));
        }
        $RoleMenu->commit();
    }
}